﻿using System;

namespace JanusLibAing.Conditions
{
    public class Condition : IdentObject
    {
        public enum EConditionType
        {
        /// <summary>
        /// public condition
        /// Start point, condition started "this" state
        /// TODOAN: +do we need it anymore? At least it is used
        /// </summary>
        START_CONDITION	= 1,

        /// <summary>
        /// public condition
        /// This condition must go to the stop state from any state
        /// TODOAN: +implement
        /// </summary>
        EXIT_ON_BREAK_CONDITION		= 2,

        /// <summary>
        /// public condition
        /// this condition could stop machine from break state only
        /// TODOAN:+Implement. +Do we need it now? but possible for the future
        /// </summary>
        BREAK_CONDITION = 4,

        /// <summary>
        /// internal timeout condition
        /// Don't raise this condition yourself only state machine allowed
        /// </summary>
        TIMEOUT_CONDITION = 5,

        /// <summary>
        /// public condition
        /// exit condition - exit from state machine
        /// start range
        /// </summary>
        EXIT_CONDITION_START	= 10,

         //End Range
        EXIT_CONDITION_END = 19,

        /// <summary>
        /// public condition
        /// universal condition go to the next state
        /// </summary>
        GOTO_CONDITION = 20,
        /// <summary>
        /// all numbers under USER_CONDITION_BEGIN reserved for system
        /// </summary>
        USER_CONDITION_BEGIN = 100,
    }
        /// <summary>
        /// default timeout condition
        /// break asynchrony current state
        /// </summary>
        public static Condition DefTimeout = new TimeoutCondition();

        /// <summary>
        /// default STOP condition
        /// exceptionally exit from state maschine
        /// </summary>
        public static Condition DefExitOnBreak = new ExitOnBreakCondition();

        /// <summary>
        /// default Exit condition
        /// standard exit. Must be assigned as ExitCondition to the last state
        /// </summary>
        public static Condition DefExitOk = new DefaultExitCondition(DefaultExitCondition.EExitCode.EXIT_OK);

        /// <summary>
        /// default exit condition
        /// exit if someting not ok with data receiving
        /// </summary>
        public static Condition DefExitNotOk = new DefaultExitCondition(DefaultExitCondition.EExitCode.EXIT_NOT_OK);

        public static Condition DefGotoNextStep = new GotoNextStepCondition();

        public Condition(Enum id) 
            : base(id)
        {
        }

        /// <summary>
        /// Clone Ctor
        /// </summary>
        protected Condition()
        {}

        public override string ToString()
        {
            return "Condition " + base.ToString();                             //MLHIDE
        }
    }
}